package com.gitee.feizns.web.domain.page;

import com.gitee.feizns.web.utils.PageUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.ibatis.session.RowBounds;

/**
 * @author feizns
 * @since 2019/7/7
 */
@ToString(exclude = "rowBounds")
public class PageAo {

    /**
     * 开始位置
     */
    @Getter
    @Setter
    private Integer offset;

    /**
     * 条目数
     */
    @Getter
    @Setter
    private Integer limit;

    /**
     * 目标页
     */
    @Getter
    @Setter
    private Integer current;

    /**
     * 页大小
     */
    @Getter
    @Setter
    private Integer size;

    /**
     * 生成的rowBounds
     */
    private RowBounds rowBounds;

    public RowBounds toRowBounds() {
        if ( rowBounds == null )
            this.rowBounds = PageUtils.toRowBounds(this);
        return rowBounds;
    }

}
